| Total Complexity | 4 |
| Total Lines | 53 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | import BaseCard from './BaseCard'; |
||
| 4 | |||
| 5 | export default class AddOptionFormCard extends BaseCard { |
||
| 6 | private readonly config: PollConfig; |
||
| 7 | |||
| 8 | constructor(config: PollConfig) { |
||
| 9 | super(); |
||
| 10 | this.config = config; |
||
| 11 | } |
||
| 12 | |||
| 13 | create(): chatV1.Schema$GoogleAppsCardV1Card { |
||
| 14 | this.buildHeader(); |
||
| 15 | this.buildSections(); |
||
| 16 | this.buildFooter(); |
||
| 17 | return this.card; |
||
| 18 | } |
||
| 19 | |||
| 20 | buildHeader() { |
||
| 21 | this.card.header = { |
||
| 22 | 'title': 'Add a new option/choice', |
||
| 23 | 'subtitle': 'Q:' + this.config.topic, |
||
| 24 | }; |
||
| 25 | } |
||
| 26 | |||
| 27 | buildSections() { |
||
| 28 | this.card.sections = [ |
||
| 29 | { |
||
| 30 | 'widgets': [ |
||
| 31 | { |
||
| 32 | 'textInput': { |
||
| 33 | 'label': 'Option Name', |
||
| 34 | 'type': 'SINGLE_LINE', |
||
| 35 | 'name': 'value', |
||
| 36 | 'hintText': '', |
||
| 37 | 'value': '', |
||
| 38 | }, |
||
| 39 | 'horizontalAlignment': 'START', |
||
| 40 | }, |
||
| 41 | ], |
||
| 42 | }, |
||
| 43 | ]; |
||
| 44 | } |
||
| 45 | |||
| 46 | buildFooter() { |
||
| 47 | this.card.fixedFooter = { |
||
| 48 | 'primaryButton': { |
||
| 49 | 'text': 'Add option', |
||
| 50 | 'onClick': { |
||
| 51 | 'action': { |
||
| 52 | 'function': 'add_option', |
||
| 53 | 'parameters': [ |
||
| 54 | { |
||
| 55 | key: 'state', |
||
| 56 | value: JSON.stringify(this.config), |
||
| 57 | }], |
||
| 64 |